<template>
    <section>
        <el-form ref="filedata" :model="filedata" label-width="93px" >
            <el-form-item label="路径"  prop="name">
                <el-col :span="24">
                    <el-tag type="success" size="medium">{{filedata.name}}</el-tag>
                    <el-button size="mini" @click="closeThisTab"><i class="fa fa-close" style="color:red;"></i></el-button>
                </el-col>

            </el-form-item>

            <el-form-item label="内容"  prop="content">
                <el-col :span="24">
                    <el-input
                            type="textarea"
                            :autosize="{ minRows: 2, maxRows: 32}"
                            placeholder="请输入内容"
                            v-model="filedata.content"
                            readonly
                            >
                    </el-input>
                </el-col>

            </el-form-item>




        </el-form>


    </section>
</template>
<script>

    import { LoadTemplateFile } from '../../api/api'
    export default {
        props: {
            filepath: "",

        },
        data() {
            return {
                bool:true,
                filedata: {
                    name: '',
                    content: "file content",
                },

            }
        },
        methods: {
            closeThisTab() {
                this.$emit('close_tab')
            },
            loadStaticFile(paramUrl) { //远程加载模板文件

                    LoadTemplateFile(paramUrl).then((res) => {
                            console.log(res)
                            this.filedata.content = res
                        }
                    )

            },

        },
        created() {
            console.log("this item is",this.filepath) //ojbk continue
            this.filedata.name = this.filepath
            //this.getWorkspace(this.deployItem.name)
            let uri = "/" + this.filepath
            this.loadStaticFile(uri)
        },


    }
</script>

